<?php
declare (strict_types = 1);

namespace app\command;

use app\common\model\Article as articleModel;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class Test extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('test')
            ->setDescription('the test command');        
    }

    protected function execute(Input $input, Output $output)
    {
    	// 指令输出
        $articleModel = new articleModel();
        $res = $articleModel->where('address_tag',null)->order('id','asc')->limit(1000)->field('id,title,address_tag')->select()->toArray();
        foreach ($res as $k=>$v){
            $a = explode(' - ',$v['title']);
            $b = end($a);
            $c = str_replace('游记攻略',"",$b);
            $articleModel->where('id',$v['id'])->update([
                'address_tag'=>$c
            ]);
        }
    	$output->writeln('test - over');
    }
}
